package com.htudata.grid.controller;


import com.htudata.common.enums.RequestSeqEnum;
import com.htudata.common.enums.RequestStatusEnum;
import com.htudata.convention.domain.ResponseResult;
import com.htudata.core.util.ResultGenerator;
import com.htudata.grid.service.GridDateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class GridDataController {

  @Autowired
  private GridDateService gridDateService;
  
  @RequestMapping(value = {"/v1/gridData/getAllReach"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getAllReach() {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_006.getCode(), this.gridDateService
          .getAllReach());
    } catch (Exception e) {
      log.error("getAllReach",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_006.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v1/gridData/getEachProportion"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getGridSumByGridType() {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_007.getCode(), this.gridDateService
          .getEachProportion());
    } catch (Exception e) {
      log.error("getGridSumByGridType",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_007.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v1/gridData/getEachReach"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getEachReach() {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_008.getCode(), this.gridDateService
          .getEachReach());
    } catch (Exception e) {
      log.error("getEachReach",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_008.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v1/gridData/getTimeFile"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getTimeFile(String future, @RequestParam String fct, int start, int size) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_020.getCode(), this.gridDateService
          .getTimeFileList(future, fct, start, size));
    } catch (Exception e) {
      log.error("getTimeFile",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_020.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
}
